<?php
namespace app\admin\validate;
use think\Validate;
class UserType extends Validate
{
    // 验证规则
    protected $rule = [
        ['type_name', 'require|unique:user_type'],
        ['Proportion','require|number|unique:user_type'],
        ['Proportion1','require|number|unique:user_type'],
    ];
    //错误信息
    protected $message  = [
        'type_name.require'    => '名称必须',
        'type_name.unique'     => '已存在相同等级名称',
        'Proportion.require'        => '佣金比例必须',
        'Proportion.number'         => '佣金比例必须是数字',
        'Proportion1.require'        => '直推分佣比例必须',
        'Proportion1.number'         => '直推分佣比例必须是数字',

    ];
    //验证场景
    protected $scene = [
        'edit'  =>  [
            'type_name'    =>'require|unique:user_type,type_name^type_id',
            'Proportion'        =>'require|number|unique:user_type,Proportion^type_id',
            'Proportion1'    =>'require|number|unique:user_type,Proportion1^type_id',
        ],
    ];
}